#!/bin/sh

mkdir -p <data_dir>/deploy_v3.0.3/data.pd/
mkdir -p <data_dir>/deploy_v3.0.3/log/

cd ~/TiExciting/pd

if test -f "pid"; then
  echo "pd-server running, kill pd..."
  kill -9 `cat pid`
  rm pid
fi

nohup ./pd-server \
    --name="<uid>" \
    --client-urls="http://<server_ip>:<status_port>" \
    --advertise-client-urls="http://<server_ip>:<status_port>" \
    --peer-urls="http://<server_ip>:<server_port>" \
    --advertise-peer-urls="http://<server_ip>:<server_port>" \
    --data-dir="<data_dir>/deploy_v3.0.3/data.pd" \
    --initial-cluster="<pd_cluster>" \
    --log-file="<data_dir>/deploy_v3.0.3/log/pd.log" 2>> "<data_dir>/deploy_v3.0.3/log/pd_stderr.log" & echo $! > pid
